package com.EdificacioAR;

import java.util.HashMap;

import android.content.res.AssetManager;

import com.Utils3D.GenericModelLoader;
import com.Utils3D.Model3D;

public class ModelFactory {

	private static ModelFactory instance = null;// Singleton instance
	private static int nextID;
	private HashMap<Integer, String> modelMap;// Maps model id to model filename
	
		
	public ModelFactory() {
		modelMap = new HashMap<Integer, String>();
		nextID = 0;
	}

	public static ModelFactory getInstance()
	{
		if (instance == null) instance = new ModelFactory();
		
		return instance;
	}
	
	public void addModel(String filename)
	{
		modelMap.put(nextID, filename);
		nextID++;
	}
	
	public void removeModel(int id)
	{
		modelMap.remove(id);
	}
	
	public Model3D getModel(int id, AssetManager assets)
	{
		String fn = modelMap.get(id);
		
		if (fn == null) return null;
		else return GenericModelLoader.loadModel(fn, assets);		
	}
	
}
